import 'package:shared_preferences/shared_preferences.dart';

class Global {
  static SharedPreferences _prefs;

  //初始化全局信息，会在APP启动时执行
  Future init() async {
    _prefs = await SharedPreferences.getInstance();
  }

  String getLoginToken(){
    if (_prefs != null) {
      try {
        return _prefs.getString("loginToken");
      } catch (e) {
        print(e);
      }
    }
    return null;
  }

  saveLoginToken(String loginToken){
    _prefs.setString("loginToken",loginToken);
  }
}